<?php get_header(); ?>
<?php get_template_part('slider'); ?>
    <!---- BODY ----->
    <div id="body" class="width-100per">
        <div id="content" class="div-center width-x1000 padding-top-x10 padding-bottom-x10">
<?php get_template_part('breadcrumbs'); ?>
            <!--- New Deal -->
            <p class="page-title">Khuyến mãi mới</p>
            <div class="product-block">
                <?php
                    query_posts('posts_per_page=8');
                    if(have_posts()) : while(have_posts()) : the_post(); 
                ?>
                <?php 
                    $img = get_post_meta($post -> ID, "imagelink1",true);
                    $price = get_post_meta($post -> ID, "price",true);
                    $discount = get_post_meta($post -> ID, "$discount",true);
                ?>
                <a href="<?php the_permalink();?>" class="product_links">
                    <?php if ( has_post_thumbnail() ) {
                    	the_post_thumbnail('thumbnail', array('class' => 'product-items'));
                        }
                        else if($img != '') {
                            echo '<div class="product-item-cover"><div style=" position: relative; background: url('. $img . ') 0 0 no-repeat; background-size: cover;" class="product-items product-item-'. $post -> ID .'"></div>
                            <div class="product-info product-info-' . $post -> ID .'">
                                <p class="product-title">' . get_the_title() . '</p>
                                <p class="product-price">Giá: ' . $price . '</p>
                                <p class="product-discount">Khuyến mãi: ' . $discount . '</p>
                            </div></div>';
                        }
                        else {
                        	echo '<div class="product-item-cover"><div style="position: relative; background: url(' . get_bloginfo( 'template_directory' ) . '/images/no_image.gif) 0 0 no-repeat; background-size: cover;" class="product-items product-item-'. $post -> ID .'"></div>
                            <div class="product-info product-info-' . $post -> ID .'">
                                <p class="product-title">' . get_the_title() . '</p>
                                <p class="product-price">Giá: ' . $price . '</p>
                                <p class="product-discount">Khuyến mãi: ' . $discount . '</p>
                            </div></div>';
                        }
                    ?>
                    <script type="text/javascript">
                        $(document).ready(function() {
                            //show / hide feedback form function
                            $('.product-item-<?php echo $post -> ID;?>').hover(function() {
                                $('.product-info-<?php echo $post -> ID;?>').animate({height:'50%', backgroundColor:'#119481'},'slow');
                            },
                            function() {
                                $('.product-info-<?php echo $post -> ID;?>').animate({height:'50px', backgroundColor:'#6CBE42'},'fast');
                            });
                        });
                    </script>
                </a>
                <?php endwhile; wp_reset_query();?>
                <?php else: ?>
                    <h1>Sorry, There are no posts to display</h1>
                <?php endif;  ?>
                <div class="clear"></div>
            </div>
            <!-- Đang bán -->
            <p class="page-title">Sản phẩm đang bán </p>
            <div class="product-block">
                <?php
                    query_posts('posts_per_page=8&category_name=hang-dang-ban');
                    if(have_posts()) : while(have_posts()) : the_post(); 
                ?>
                <?php 
                    $img = get_post_meta($post -> ID, "imagelink1",true);
                    $price = get_post_meta($post -> ID, "price",true);
                    $pricevn = get_post_meta($post -> ID, "pricevn",true);
                ?>
                <a href="<?php the_permalink();?>" class="product_links">
                    <?php if ( has_post_thumbnail() ) {
                    	the_post_thumbnail('thumbnail', array('class' => 'product-items'));
                        }
                        else if($img != '') {
                            echo '<div class="product-item-cover"><div style="position: relative; background: url('. $img . ') 0 0 no-repeat; background-size: cover;" class="product-items my-product-item-'. $post -> ID .'"></div>
                            <div class="product-info my-product-info-' . $post -> ID .'">
                                <p class="product-title">' . get_the_title() . '</p>
                                <p class="product-price">Giá: ' . $price . '</p>
                                <p class="product-discount">Khuyến mãi: ' . $discount . '</p>
                            </div></div>';
                        }
                        else {
                            echo '<div class="product-item-cover"><div style="position: relative; background: url(' . get_bloginfo( 'template_directory' ) . '/images/no_image.gif) 0 0 no-repeat; background-size: cover;" class="product-item my-product-item-'. $post -> ID .'"></div>
                            <div class="product-info my-product-info-' . $post -> ID .'">
                                <p class="product-title">' . get_the_title() . '</p>
                                <p class="product-price">Giá: ' . $price . '</p>
                                <p class="product-discount">Khuyến mãi: ' . $discount . '</p>
                            </div></div>';
                        }
                    ?>
                    <script type="text/javascript">
                        $(document).ready(function() {
                            //show / hide feedback form function
                            $('.my-product-item-<?php echo $post -> ID;?>').hover(function() {
                                $('.my-product-info-<?php echo $post -> ID;?>').animate({height:'50%', backgroundColor:'#119481'},'slow');
                            },
                            function() {
                                $('.my-product-info-<?php echo $post -> ID;?>').animate({height:'50px', backgroundColor:'#6CBE42'},'fast');
                            });
                        });
                    </script>
                </a>
                <?php endwhile; wp_reset_query();?>
                <?php else: ?>
                    <h1>Sorry, There are no posts to display</h1>
                <?php endif;  ?>
                <div class="clear"></div>
            </div>
<?php get_template_part('aboutus','index'); ?>
        </div>
    </div> 
<?php get_footer(); ?>